home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************\
-
- File: sfx.c
-
- Purpose: This module handles demo initialization/shutdown and a
- dispatch for the graphic effects and fades.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program in a file named "GNU General Public License".
- If not, write to the Free Software Foundation, 675 Mass Ave,
- Cambridge, MA 02139, USA.
-
- \**********************************************************************/
-
- #include "sfx.h"
- #include "sfx main window.h"
- #include "sfx install.h"
- #include "sfx gestalt.h"
- #include "program globals.h"
- #include "error.h"
-
- short gModuleIndex;
- char gChooseRandom, gOnRestart, gOnShutdown, gFadeEarly;
- Str255 gModuleName;
-
- void InitTheProgram(void)
- {
- gModuleName[0]=0x00;
-
- if (!sfxGestaltFunctionInstalledQQ())
- {
- HandleError(MakeNewGestaltSelectors(), TRUE, FALSE);
- HandleError(SetGestaltProcPtrs(0L, 0L, 0L), FALSE, FALSE);
- HandleError(InstallTheShutdownProc(0, "\p", gOnShutdown, gOnRestart, gFadeEarly,
- FALSE, TRUE), FALSE, FALSE);
- }
- else
- {
- HandleError(RemoveTheFade(), FALSE, FALSE);
- }
-
- SetIndDispatchProc(kMainWindow, MainWindowDispatch);
- CallIndDispatchProc(kMainWindow, kStartup, 0L);
- CallIndDispatchProc(kHelp, kStartup, 0L); /* must be called after PreferencesInit */
- }
-
- void ShutDownTheProgram(void)
- {
- enum ErrorTypes resultCode;
-
- CallIndDispatchProc(kMainWindow, kShutdown, 0L);
-
- resultCode=allsWell;
- if (gModuleName[0]!=0x00)
- resultCode=InstallTheShutdownProc(gModuleIndex, gModuleName, gOnShutdown,
- gOnRestart, gFadeEarly, TRUE, FALSE);
- if (resultCode!=allsWell)
- {
- switch (resultCode)
- {
- case kModuleDamaged:
- case kCantOpenModule:
- SetErrorParameters("\pFade module: ", gModuleName, "\p");
- HandleError(resultCode, FALSE, TRUE);
- break;
- }
- }
- }
-